package com.zhangx.remote.receiver;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @ClassName TopicReceiver
 * @Description 按照主题接收，这种更灵活，可以自动创建队列
 * @Author zhangx
 * @Date 2021/2/20 10:36
 **/
@Slf4j
@Component
@RabbitListener(bindings=@QueueBinding(
        value=@Queue(value="topic.human",autoDelete="true"),
        exchange=@Exchange(value="topicExchange",type= ExchangeTypes.TOPIC),
        key="topic.#"
)
)
public class TopicReceiver {
    @RabbitHandler
    private void process(Map message) {
        log.info("接收到info日志："+message.toString());
    }
}
